package com.lhd.study.controller;

import com.lhd.study.server.TitleListServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;


@Controller
@RequestMapping("/titleList")
public class TitleListController {

    @Autowired
    private TitleListServer server;

    @RequestMapping("/list")
    @ResponseBody
    public Map<String, Object> getTitleList() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 1);
        map.put("msg", "获取成功");
        map.put("data", server.getTitleList());
        return map;
    }

    @RequestMapping("/news")
    @ResponseBody
    public Map<String, Object> getNewsList(@RequestParam(name = "id") int id) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 1);
        map.put("msg", "获取成功");
        map.put("data", server.getNewsList(id));
        return map;
    }


}
